//引入express框架
const express = require('express');
//创建网站服务器
const app = express();

//接收所有请求的中间件
app.use((req,res,next) =>{
    console.log('请求走了app.use中间件');
    next();
});

//当客户端访问/request请求的时候走当前中间件
app.use('/request',(req,res,next) =>{
    console.log('请求走了app.use / request中间件');
    next();
});

app.get('/list',(req,res,next) =>{
    res.send('/list');
});

app.get('/request',(req,res,next) =>{
    req.name = 'Mr.lizeyan-victor';
    //定义中间件会继续向下查找
    next();
});
app.get('/request',(req,res,next) =>{
    res.send(req.name);
});
//监听端口
app.listen(3000);
console.log('Welcome to express，Mr.lizeyan-victor');